package last.fm;

/***
 * @author Ragnvald Fuglestein
 */

import java.util.List;

import baseStructure.Log;
import baseStructure.SortedList;
import baseStructure.Track;
import library.Library;
import library.PlayList;

public class MakeLastFmLovedList {
	private static MakeLastFmLovedList instance;
	static {
		instance = new MakeLastFmLovedList();
	}
	public static MakeLastFmLovedList getInstance() {
		return instance;
	}
	
	private MakeLastFmLovedList() { }
	
	public void lastFmUserLovedTracksCallback(List<LastFmTrackAddon> list) {
		PlayList tracklist = Library.getInstance().playlists.get("default");
		SortedList<Track> tl = new SortedList<>();
		for (LastFmTrackAddon track : list) {
			Library.getInstance().getTracks(tl, track.toSearch());
			if (tl.size() > 0) {
				for (Track t : tl) {
					tracklist.append(t);
				}
			} else {
				Log.i("NOT FOUND IN LIBRARY: " + track.toString());
			}
		}
	}
}
